import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Demo1 {
    public static void main(String[] args) throws Exception {
//        导入jar包
//        注册驱动
        Class.forName("com.mysql.jdbc.Driver");
//        获取链接
        Connection  con= DriverManager.getConnection("jdbc:mysql://localhost:3306/db8", "root", "root");
//        获取执行对象
        Statement statement = con.createStatement();
        String s = "SELECT * FROM account";
        ResultSet resultSet = statement.executeQuery(s);
//        处理结果
        while(resultSet.next()){
            System.out.println(resultSet.getInt("id")+"\t"+resultSet.getString("NAME"));
        }
        con.close();
        statement.close();
        resultSet.close();
    }
}
